GailImageCell: Deal with absence of pixbufs
authorMatthias Clasen <mclasen@redhat.com>
Tue, 21 Jun 2011 22:52:24 +0000 (18:52 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:02 +0000 (16:08 -0400)
...and when there are pixbufs, don't leak them.

gtk/a11y/gailimagecell.c

index 078b4b7cacc20b22d3bc353107dc4359b309c3d2..b35b37eba9bae3da8df77299998d9c37b3b6fd97 100644 (file)
@@ -160,11 +160,16 @@ gail_image_cell_get_image_size (AtkImage *image,
 {
   GailImageCell *cell = GAIL_IMAGE_CELL (image);
   GtkCellRenderer *cell_renderer;
-  GdkPixbuf *pixbuf;
+  GdkPixbuf *pixbuf = NULL;
 
   cell_renderer  = GAIL_RENDERER_CELL (cell)->renderer;
   g_object_get (GTK_CELL_RENDERER_PIXBUF (cell_renderer), "pixbuf", &pixbuf, NULL);
 
-  *width = gdk_pixbuf_get_width (pixbuf);
-  *height = gdk_pixbuf_get_height (pixbuf);
+  if (pixbuf)
+    {
+      *width = gdk_pixbuf_get_width (pixbuf);
+      *height = gdk_pixbuf_get_height (pixbuf);
+
+      g_object_unref (pixbuf);
+    }
 }